package com.disapand.dingdang.model

import org.ktorm.schema.Table
import org.ktorm.schema.boolean
import org.ktorm.schema.datetime
import org.ktorm.schema.int
import kotlin.reflect.KClass

/**
 * @author disapand
 * @date 2022/3/29 - 11:12 星期二
 */
open class BaseTable<E: BaseEntity<E>>(
    tableName: String,
    alias: String? = "",
    catalog: String? = "",
    schema: String? = "",
    entityClass: KClass<E>? = null,
): Table<E>(tableName, alias, catalog, schema, entityClass) {
    val status = int("status").bindTo { it.status }
    val deleted = boolean("deleted").bindTo { it.deleted }
    val createdAt = datetime("created_at").bindTo { it.createdAt }
    val createdBy = int("created_by").bindTo { it.createdBy }
    val updatedAt = datetime("updated_at").bindTo { it.updatedAt }
    val updatedBy = int("updated_by").bindTo { it.updatedBy }
}